<?php

namespace App\Http\Controllers\Alipay;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\libs\alipay\pagepay\buildermodel\AlipayTradePagePayContentBuilder;
use App\libs\alipay\pagepay\service\AlipayTradeService;

class AlipayController extends Controller
{
    public function alipayWapPay(Request $request){
//        require_once __DIR__.'../../../libs/alipay/pagepay/buildermodel';
//        require_once __DIR__.'../../../libs/alipay/pagepay/service/AlipayTradeService.php';
//        require_once "D:/phpstudy/WWW/wwwlwcom/".'app/libs/alipay/pagepay/buildermodel/AlipayTradePagePayContentBuilder.php';
//        require_once "D:/phpstudy/WWW/wwwlwcom/".'app/libs/alipay/pagepay/service/AlipayTradeService.php';
//        require_once "../../../libs/alipay/pagepay/buildermodel";
//        require_once "../../../libs/alipay/pagepay/service/AlipayTradeService.php";

        $out_trade_no = date('Ymd',time()).md5(rand(100,999));        //公共方法生成唯一订单号
        $subject = '野生奥特曼一只';                     //商品名称
        $total_amount = 1;                         //商品价格
        $body = 'test test!';                       //订单描述
        $timeout_express="1m";

        //构造参数AlipayTradePagePayContentBuilder
        $payRequestBuilder = new AlipayTradePagePayContentBuilder();
        $payRequestBuilder->setBody($body);
        $payRequestBuilder->setSubject($subject);
        $payRequestBuilder->setTotalAmount($total_amount);
        $payRequestBuilder->setOutTradeNo($out_trade_no);

        $aop = new AlipayTradeService($payRequestBuilder);

        $response = $aop->pagePay($payRequestBuilder,config('alipay.return_url'),config('alipay.notify_url'));
        //输出表单
        var_dump($response);
    }
    //同步跳转
    public function return(){

    }
    //异步通知
    public function alipay(){

    }
}
